import Request from "@/api/Request";
import GenTemplateGroupVO from "@/domain/vo/GenTemplateGroupVO";
import PathVariable from "@/domain/po/PathVariable";
import GenTemplateGroupFormBO from "@/domain/bo/GenTemplateGroupFormBO";
import GenTemplateFileVO from "@/domain/vo/GenTemplateFileVO";
import GenTemplateFileBO from "@/domain/bo/GenTemplateFileBO";

class GenTemplateService {

    /**
     * 查询模板组数据
     */
    public groupList(): Promise<Array<GenTemplateGroupVO>> {
        return Request
            .build("/api/gen/template/group/list")
            .doGet(undefined);
    }

    /**
     * 添加
     */
    public addGroup(bo: GenTemplateGroupFormBO) {
        return Request
            .build("/api/gen/template/group/add")
            .doPost(bo);
    }

    /**
     * 编辑
     */
    public editGroup(bo: GenTemplateGroupFormBO) {
        return Request
            .build("/api/gen/template/group/edit/{id}")
            .pathVariable([new PathVariable("id", bo.id)])
            .doPut(bo);
    }

    /**
     * 删除
     */
    public delGroup(ids: string[]) {
        return Request
            .build("/api/gen/template/group/del")
            .doDelete(ids);
    }

    /**
     * 获取模板信息
     */
    public getTempById(id: string): Promise<GenTemplateFileVO> {
        return Request
            .build("/api/gen/template/file/{id}")
            .pathVariable([new PathVariable("id", id)])
            .doGet(undefined);
    }

    /**
     * 下载文件信息
     */
    public downloadTempById(id: string): Promise<any> {
        return Request
            .build("/api/gen/template/file/download/{id}")
            .pathVariable([new PathVariable("id", id)])
            .doGet(undefined);
    }

    /**
     * 添加模板文件
     * @param genTemplateFileBO
     */
    public addTmp(genTemplateFileBO: GenTemplateFileBO) {
        return Request
            .build("/api/gen/template/file/add")
            .doPostFormData(genTemplateFileBO);
    }

    /**
     * 编辑模板文件
     * @param id
     * @param genTemplateFileBO
     */
    public editTmpById(id: string, genTemplateFileBO: GenTemplateFileBO) {
        return Request
            .build("/api/gen/template/file/edit/{id}")
            .pathVariable([new PathVariable("id", id)])
            .doPostFormData(genTemplateFileBO);
    }

    /**
     * 删除模板文件
     * @param ids
     */
    public delTmpById(ids: string[]) {
        return Request
            .build("/api/gen/template/file/del")
            .doDelete(ids);
    }
}

export default new GenTemplateService();